<div class='resource-details'>
  <div class="row">
    <div class="col-sm-12">
      <h3>Status</h3>
      <dl class="dl-horizontal left">
        <dt>Status:</dt>
        <dd>
          <status-icon status="build.status.phase"></status-icon>
          {{build.status.phase}}
          <span ng-if="build | jenkinsLogURL">
            <span class="text-muted">&ndash;</span>
            <a ng-href="{{build | jenkinsLogURL}}" target="_blank">View Log</a>
          </span>
        </dd>
        <dt>Started:</dt>
        <dd>
          <span ng-if="build.status.startTimestamp">
            <relative-timestamp timestamp="build.status.startTimestamp"></relative-timestamp>
            <span><span class="text-muted">&ndash;</span> {{build.status.startTimestamp | date : 'MMM dd, yyyy h:mm a'}}</span>
          </span>
          <span ng-if="!build.status.startTimestamp"><em>not started</em></span>
        </dd>
        <dt>Duration:</dt>
        <dd>
          <span ng-switch="build.status.phase" class="hide-ng-leave">
            <span ng-switch-when="Complete">{{(build.status.startTimestamp || build.metadata.creationTimestamp) | duration : build.status.completionTimestamp}}</span>
            <span ng-switch-when="Failed">{{build.status.startTimestamp | duration : build.status.completionTimestamp}}</span>
            <span ng-switch-when="Running">running for <duration-until-now timestamp="build.status.startTimestamp"></duration-until-now></span>
            <span ng-switch-when="New">waiting for <duration-until-now timestamp="build.metadata.creationTimestamp"></duration-until-now></span>
            <span ng-switch-when="Pending">waiting for <duration-until-now timestamp="build.metadata.creationTimestamp"></duration-until-now></span>
            <span ng-switch-default>
              <span ng-if="build.status.startTimestamp">{{build.status.startTimestamp | duration : build.status.completionTimestamp}}</span>
              <span ng-if="!build.status.startTimestamp">waited for {{build.metadata.creationTimestamp | duration : build.status.completionTimestamp}}</span>
            </span>
          </span>
        </dd>
        <div ng-if='build.spec.triggeredBy.length'>
          <dt>Triggered by:</dt>
          <dd>
            <div ng-repeat="trigger in build.spec.triggeredBy">
              <div ng-switch="trigger.message">
                <span ng-switch-when="Manually triggered">Manual build</span>
                <span ng-switch-when="GitHub WebHook">
                  <ng-include src=" 'views/_webhook-trigger-cause.html' "></ng-include>
                </span>
                <span ng-switch-when="Generic WebHook">
                  <ng-include src=" 'views/_webhook-trigger-cause.html' "></ng-include>
                </span>
                <span ng-switch-when="Image change">
                  {{trigger.message}} for {{trigger.imageChangeBuild.fromRef.name}}
                </span>
                <span ng-switch-default>{{trigger.message}}</span>
              </div>
            </div>
          </dd>
        </div>
      </dl>
      <h3>Configuration <span class="small" ng-if="buildConfigName">created from <a href="{{build | configURLForResource}}">{{buildConfigName}}</a></span></h3>
      <dl class="dl-horizontal left">
        <dt>Build strategy:</dt>
        <dd>{{build.spec.strategy.type | startCase}}</dd>
        <dt ng-if-start="(build | buildStrategy).from">Builder image:</dt>
        <dd ng-if-end class="truncate">{{(build | buildStrategy).from | imageObjectRef : build.metadata.namespace}}<span ng-if="!(build | buildStrategy).from"><em>none</em></span></dd>
        <dt>Source type:</dt>
        <dd>{{build.spec.source.type}}</dd>
        <dt ng-if-start="build.spec.source.git.uri">Source repo:</dt>
        <dd ng-if-end><span class="word-break"><osc-git-link
                    uri="build.spec.source.git.uri"
                    ref="build.spec.source.git.ref"
                    context-dir="build.spec.source.contextDir">{{build.spec.source.git.uri}}</osc-git-link></span></dd>
        <dt ng-if-start="build.spec.source.git.ref">Source ref:</dt>
        <dd ng-if-end>{{build.spec.source.git.ref}}</dd>
        <dt ng-if-start="build.spec.source.contextDir">Source context dir:</dt>
        <dd ng-if-end>{{build.spec.source.contextDir}}</dd>
        <dt ng-if-start="build.spec.output.to">Output image:</dt>
        <dd ng-if-end>{{build.spec.output.to | imageObjectRef : build.metadata.namespace}}</dd>
        <dt ng-if-start="build.spec.output.pushSecret.name">Push secret:</dt>
        <dd ng-if-end>{{build.spec.output.pushSecret.name}}</dd>
        <dt ng-if-start="build.spec.strategy.jenkinsPipelineStrategy.jenkinsfilePath">
          Jenkinsfile Path:
        </dt>
        <dd ng-if-end>
          <span ng-if="build | jenkinsfileLink">
            <a ng-href="{{build | jenkinsfileLink}}">{{build.spec.strategy.jenkinsPipelineStrategy.jenkinsfilePath}}</a>
          </span>
          <span ng-if="!(build | jenkinsfileLink)">
            {{build.spec.strategy.jenkinsPipelineStrategy.jenkinsfilePath}}
          </span>
        </dd>
        <dt ng-if-start="build.spec.strategy.jenkinsPipelineStrategy.jenkinsfile">
          Jenkinsfile:
        </dt>
        <dd></dd>
        <div ng-if-end ui-ace="{
          mode: 'groovy',
          theme: 'eclipse',
          showGutter: false,
          rendererOptions: {
            fadeFoldWidgets: true,
            highlightActiveLine: false,
            showPrintMargin: false
          },
          advanced: {
            highlightActiveLine: false
          }
        }" readonly ng-model="buildConfig.spec.strategy.jenkinsPipelineStrategy.jenkinsfile" class="ace-bordered ace-inline ace-read-only mar-top-md"></div>
      </dl>
    </div>
  </div>
  <annotations annotations="build.metadata.annotations"></annotations>
</div>
